//#include <iostream>
//
//using namespace std;
//typedef long long LL;
//const int N = 1e6 + 10;
//LL n, p;
//LL f[N], g[N];
//LL qpow(LL a, LL b, LL p)
//{
//	LL ret = 1;
//	while (b)
//	{
//		if (b & 1) ret = ret * a % p;
//		a = a * a % p;
//		b >>= 1;
//	}
//}
//void init()
//{
//	f[0] = 1;
//	for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % p;
//	g[n] = qpow(f[n], p - 2, p);
//	for (int i = n - 1; i >= 0; i--)
//	{
//		g[i] = g[i + 1] * (i + 1) % p;
//	}
//}
//LL C(int n, int m)
//{
//	if (n < m) return 0;
//	return f[n] * g[n - m] % p * g[m] % p;
//}
//int main()
//{
//
//	return 0;
//}
#include <iostream>
using namespace std;
typedef long long LL;
const int N = 5e6 + 10, MOD = 998244353;
int n;
LL f[N], g[N];
LL qpow(LL a, LL b, LL p)
{
	LL ret = 1;
	while (b)
	{
		if (b & 1) ret = ret * a % p;
		b >>= 1;
		a = a * a % p;
	}
	return ret;
}
void init()
{
	f[0] = 1;
	for (int i = 1; i <= n; i++)
		f[i] = f[i - 1] * i % MOD;
	g[n] = qpow(f[n], MOD - 2, MOD);
	for (int i = n - 1; i >= 0; i--)
		g[i] = (i + 1) * g[i + 1] % MOD;
}
int main()
{
	int T;
	scanf("%d%d", &T, &n);
	init();
	LL ret = 0;
	while (T--)
	{
		int n, m; scanf("%d%d", &n, &m);
		ret ^= (f[n] * g[n - m] % MOD * g[m] % MOD);
	}
	printf("%lld\n", ret);
	return 0;
}


